package com.bobi.tfca.utils;

import java.util.Random;

/**
 * @author 李文发
 * @date 2024/4/21
 */
public class Generate4NumberUtils {
    public static String generateCheckCode() {
        //定义取值范围
        String str = "0123456789";
        //容量为4
        StringBuilder sb = new StringBuilder(4);
        for (int i = 0; i < 4; i++) {
            //遍历4次，拿到某个字符并且拼接
            char ch = str.charAt(new Random().nextInt(str.length()));
            sb.append(ch);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        System.out.println(generateCheckCode());
    }
}


